package com.vitech.javacertification.threads.hungrybirds;

public class WormsDish {

	private int numberofWorms = 5;
	private boolean empty = false;

	public synchronized boolean eatWorms() {

		if (numberofWorms >= 1) {
			numberofWorms--;
			System.out.println("Number of worms = " + numberofWorms);
		}

		if (numberofWorms == 0) {
			empty = true;
		}
		return !empty;
	}

	public void parentAddsWorm(int numberofWorms) {

		this.numberofWorms = numberofWorms;
		empty = false;
	}

	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return empty;
	}
}